#include <stdio.h>

int main()
{
	const int DIFFERENCE = 8 * 60;
	const int ONEDAY = 24 * 60;
    int bjt, utc, minute1, minute2; 
	int utchour,utcminute;
	int a,b,c,d;
	scanf("%d", &bjt);
	if(0<= bjt && bjt <= 2359){
		if(bjt < 800){
			minute1 = (bjt / 100) * 60 + bjt % 100;
			minute2 = minute1 - DIFFERENCE;	
			utc = ONEDAY + minute2;  
			utchour = utc / 60;
			utcminute = utc % 60; 
			utc = utchour * 100 + utcminute;
			a = utc / 1000;
			b = utc / 100 % 10;
			c = utc / 10 % 10;
			d = utc % 10;
			utc = a * 1000 + b * 100 + c * 10 + d;
			printf("%d", utc);	
		}else{
			minute1 = (bjt / 100) * 60 + bjt % 100;
			minute2 = minute1 - DIFFERENCE;	
			utchour = minute2 / 60;
			utcminute = minute2 % 60;
			utc = utchour * 100 + utcminute;
			a = utc / 1000;
			b = utc / 100 % 10;
			c = utc / 10 % 10;
			d = utc % 10;
			utc = a * 1000 + b * 100 + c * 10 + d;
			printf("%d", utc);		
		}
	}
	return 0; 
	
}	
